<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<!--head部分-->
<head th:include="layout :: htmlhead" th:with="title='后台管理'">
</head>
<body class="layui-layout-body">
    <div class="layui-layout layui-layout-admin">
        <!--头-->
        <div th:replace="fragments/head :: header"></div>
        <div class="layui-body">
        
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
  <legend>排产结果查看</legend>
</fieldset>

    <div class="layui-inline">
      <label class="layui-form-label">截止日期</label>
      <div class="layui-input-inline">
        <input name="date" id="date" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input" type="text">
      </div>
      <button class="layui-btn"  lay-filter="demo1">查询</button>
    </div>
    <div class="layui-btn-group">
        <button class="layui-btn" id="btn-newproduct">导出排产</button>
        <button class="layui-btn" id="btn-refresh">刷新计算</button>
    </div>
<table class="layui-table" lay-data="{url:'/getPurchaseResult',page:true, id:'test3'}" lay-filter="test3">
  <thead>
    <tr>
<th lay-data="{field:'cinvcode', width:100, edit: 'text'}">存货编码</th>
<th lay-data="{field:'cinvaddcode', width:100, edit: 'text'}">存货代码</th>
<th lay-data="{field:'cinvname', width:100, edit: 'text'}">存货名称</th>
<th lay-data="{field:'cinvstd', width:100, edit: 'text'}">存货型号</th>
<th lay-data="{field:'fquantity', width:100, edit: 'text'}">要求产量</th>
<th lay-data="{field:'stockquantity', width:100, edit: 'text'}">库存量</th>
<th lay-data="{field:'purchasequantity', width:100, edit: 'text'}">预计采购量</th>
<th lay-data="{field:'quantity', width:100, edit: 'text', sort: true}">可用数量</th>
<th lay-data="{field: 'cancomplete', width: 180, align: 'center', templet: '#titleTpl'}">库存满足</th>
    </tr>
  </thead>
</table>
<script type="text/html" id="titleTpl">
  {{#  if(d.fquantity > d.stockquantity+d.purchasequantity){ }}
    <i class="layui-icon layui-icon-rate layui-bg-red">需补充采购</i>
  {{#  } else if (d.fquantity <= d.stockquantity+d.purchasequantity && d.fquantity > d.stockquantity){ }}
    <i class="layui-icon layui-icon-rate-half layui-bg-orange">采购可满足</i>
  {{#  } else { }}
    <i class="layui-icon layui-icon-rate-solid layui-bg-green">库存可满足</i>
  {{#  } }}
</script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
layui.use(['laydate' , 'table'], function(){
  var layer = layui.layer
  ,laydate = layui.laydate
  ,table = layui.table;
  
  //日期
  laydate.render({
    elem: '#date'
  });
  //监听工具条
  table.on('tool(test3)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
    var data = obj.data //获得当前行数据
    ,layEvent = obj.event; //获得 lay-event 对应的值
    if(layEvent === 'detail'){
      layer.msg('查看操作');
    } else if(layEvent === 'del'){
      layer.confirm('真的删除行么', function(index){
        obj.del(); //删除对应行（tr）的DOM结构
        layer.close(index);
        //向服务端发送删除指令
      });
    } else if(layEvent === 'edit'){
      layer.msg('编辑操作');
    }
  });
});
</script>
        </div>
        <!--底部-->
        <div th:replace="fragments/footer :: footer"></div>
    </div>
</body>
</html>